package com.github.baichuan.application.dashboard.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.http.CacheControl;
import org.springframework.web.reactive.config.ResourceHandlerRegistry;
import org.springframework.web.reactive.config.WebFluxConfigurer;

import java.util.concurrent.TimeUnit;

@Configuration
public class WebFluxConfig implements WebFluxConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/*")
                .addResourceLocations("file:./public/")
                .setCacheControl(CacheControl.maxAge(1, TimeUnit.DAYS))
                .resourceChain(true);

//        registry.addResourceHandler("/excel/*")
//                .addResourceLocations("file:./excel/")
//                .setCacheControl(CacheControl.noCache())
//                .resourceChain(true);

        registry.addResourceHandler("/assets/**")
                .addResourceLocations("file:./public/assets/")
                .setCacheControl(CacheControl.maxAge(1, TimeUnit.DAYS))
                .resourceChain(true);
    }
}
